
class SegmentTreeNode:
    def __init__(self, start, end, count):
        self.start, self.end, self.count = start, end, count
        self.left, self.right = None, None


class Solution:
    """
    @param: root: The root of segment tree.
    @param: start: start value.
    @param: end: end value.
    @return: The count number in the interval [start, end]
    """

    COUNT = 0

    def query(self, root, start, end):
        if root is None:
            return 0

        # write your code here
        if start <= root.start and end >= root.end:
            return root.count

        if start > root.end or end < root.start:
            # no overlap
            return self.COUNT

        return self.query(root.left, start, end) + self.query(root.right, start, end)
